package com.qst.mapreduce.wordcount.zuoyemywc.shiyanzuoye.zuoye1;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class WordCountMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, IntWritable>.Context context) throws IOException, InterruptedException {
        System.out.println(key);
        System.out.println(value);
        String line = value.toString();
        String[] words = line.split(",\\s* ");
        if ( words.length ==3){
            Text outkey = new Text(words[2]);
            IntWritable outValue = new IntWritable(1);
            context.write(outkey, outValue);
        }

    }
}
